package com.wd.mvp.presenter;


import com.wd.mvp.listener.OnDemoFinishedListener;
import com.wd.mvp.model.DemoModelImpl;
import com.wd.mvp.model.IDemoModel;
import com.wd.mvp.view.IDemoView;

/**
 * NA<BR>
 *
 * @author w4425
 * @version [V2.0.0, 2021/3/17]
 * @since V2.0.0
 */
public class DemoPresenterImpl implements IDemoPresenter {
    private IDemoView view;
    private IDemoModel model;

    public DemoPresenterImpl(IDemoView view) {
        this.view = view;
        if (model == null) {
            model = new DemoModelImpl();
        }
    }

    @Override
    public void textDemo(String text) {
        if (model != null) {
            if (view == null) {
                return;
            }
            model.textDemo(text, new OnDemoFinishedListener() {
                @Override
                public void onSuccess(String msg) {
                    view.showSuccess(msg);
                }

                @Override
                public void onFail(String msg) {
                    view.fail(msg);
                }
            });
        }
    }

    @Override
    public void onDestroy() {
    }
}
